package com.ebuy.api.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ebuy.api.domain.TbUser;
import com.ebuy.api.mapper.TbUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: ren.zhong@chebada.com
 * @date: 2023年09月12日11:00:01
 **/
@Service
public class UserService extends ServiceImpl<TbUserMapper, TbUser> {
    @Autowired
    TbUserMapper tbUserMapper;


    public TbUser getByMobile(String mobile) {
        LambdaQueryWrapper<TbUser> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TbUser::getMobile, mobile);
        return super.getOne(wrapper);
    }

    public boolean setStatus(Integer status,List<Integer> ids){
        LambdaQueryWrapper<TbUser> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(TbUser::getId, ids);
        List<TbUser> tbUserList=super.list(wrapper);
        tbUserList.forEach(u->u.setStatus(status));
        return super.updateBatchById(tbUserList);
    }

}